package com.zymail.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.zymail.bean.ZyClass;
import com.zymail.vo.GoodsCategory;
import org.springframework.stereotype.Service;


@Service
public class GoodsCategoryImpl implements GoodsCategoryService {

    @Autowired
    private ZyClassService classService;

    @Override
    public List<GoodsCategory> getGoodsCategories() {
        List<ZyClass> zyClasses = classService.list();
        ArrayList<GoodsCategory> goodsCategories = new ArrayList<>();
        for (ZyClass zyClass : zyClasses) {
            GoodsCategory goodsCategory = GoodsCategory.builder().categoryId(zyClass.getId()).categoryName(zyClass.getName()).parentId(zyClass.getFaId()).build();
            goodsCategories.add(goodsCategory);
        }
        return goodsCategories;
    }
}
